package com.syni.mdd.yhd.common.all.service.impl.activity;

import com.syni.mdd.yhd.common.all.dao.jpa.activity.BmsDrLogicDao;
import com.syni.mdd.yhd.common.all.entity.activity.BmsDrLogic;
import com.syni.mdd.yhd.common.all.service.activity.BmsDrLogicService;
import com.syni.mdd.yhd.common.all.service.impl.BaseService;
import com.syni.mdd.yhd.common.all.utils.SpecificationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @className
 * @description TOO
 * @Author hwq
 * @DATE 2019/9/23 10:34
 * @VERSION 1.0
 **/
@Service
public class BmsDrLogicImpl extends BaseService<BmsDrLogic, Integer> implements BmsDrLogicService {

    @Autowired
    RedisTemplate redisTemplate;

    @Autowired
    BmsDrLogicDao bmsDrLogicDao;

    @Override
    public BmsDrLogicDao getBaseDao() {
        return bmsDrLogicDao;
    }

    @Override
    public List<BmsDrLogic> getUserTask(Integer userId) {
        return bmsDrLogicDao.findByUserId(userId);
    }

    @Override
    public Integer countNumInDate(Date startTime, Date endTime, int i) {
        Map<String,Object> conditionMap = new LinkedHashMap<>();
        conditionMap.put("newTime_GTTE",startTime);
        conditionMap.put("newTime_LTT",endTime);
        conditionMap.put("completeNum",i);
        List<BmsDrLogic> bmsDrLogics = bmsDrLogicDao.findAll(new SpecificationUtils(conditionMap));
        return bmsDrLogics.size();
    }
}
